package test;

import interpreter.AssignExpr;
import interpreter.DivideBinExpr;
import interpreter.ExprSeq;
import interpreter.Id;
import interpreter.MinusUnExpr;
import interpreter.Num;
import interpreter.PlusBinExpr;
import interpreter.PlusUnExpr;

public class Main {
	public static void main(String[] args) {
		try{
			System.out.println("// 1.23 ==> 1.23");
			System.out.println(Num._("1.23").eval());
			System.out.println("--------------------------");
		}catch(Exception e){
			System.out.println(e);
		}
			
		try{
			System.out.println("// 1 / 0 ==> exception");
			System.out.println(
				    DivideBinExpr._(
				            Num._("1"),
				            Num._("0")).eval());
			System.out.println("--------------------------");
		} catch (Exception e){
			System.out.println(e);
		}
			
		try{
			System.out.println("// x = 2.34 ==> 2.34");
			System.out.println(AssignExpr._(
			        Id._('x'),
			        Num._("2.34")).eval());
			System.out.println("--------------------------");
		}catch(Exception e){
			System.out.println(e);
		}
			
		try{
			System.out.println("// x = x ==> exception");
			System.out.println(AssignExpr._(
			        Id._('x'),
			        Id._('x')).eval());
			System.out.println("--------------------------");
		}catch(Exception e){
			System.out.println(e);
		}
			
		try{
			System.out.println("// x = -(3.45); x ==> -3.45");
			System.out.println(ExprSeq._(
        AssignExpr._(
            Id._('x'),
            MinusUnExpr._(
                Num._("3.45"))),
        Id._('x')).eval());
			System.out.println("--------------------------");
		}catch(Exception e){
			System.out.println(e);
		}
			
		try{
			System.out.println("// x = y = 3.45; x / y ==> 1");
			System.out.println(ExprSeq._(
			        AssignExpr._(
			                Id._('x'),
			                AssignExpr._(
			                    Id._('y'),
			                    Num._("3.45"))),
			            DivideBinExpr._(
			                Id._('x'),
			                Id._('y'))).eval());
			System.out.println("--------------------------");
		}catch(Exception e){
			System.out.println(e);
		}
			
		try{
			System.out.println("// x = 1; x + (x = 2) ==> 3");
			System.out.println(ExprSeq._(
			        AssignExpr._(
			                Id._('x'),
			                Num._("1")),
			            PlusBinExpr._(
			                Id._('x'),
			                AssignExpr._(
			                    Id._('x'),
			                    Num._("2")))).eval());
			System.out.println("--------------------------");
		}catch(Exception e){
			System.out.println(e);
		}
			
		try{
			System.out.println("// x = 1; (x = 2) + x ==> 4");
			System.out.println(ExprSeq._(
			        AssignExpr._(
			                Id._('x'),
			                Num._("1")),
			            PlusBinExpr._(
			                AssignExpr._(
			                    Id._('x'),
			                    Num._("2")),
			                Id._('x'))).eval());
		}catch(Exception e){
			System.out.println(e);
		}
	}
}
